package demo2;

public class Test {
    public static void drawMap(Shape shape){
        shape.draw();
    }
    public static void main1(String[] args) {
        Rect rect=new Rect();
        drawMap(rect);
        Circle circle=new Circle();
        drawMap(circle);
        Triangle triangle=new Triangle();
        drawMap(triangle);
    }

    public static void main2(String[] args) {
        Rect rect=new Rect();
        Circle circle=new Circle();
        Triangle triangle=new Triangle();
        String[] string={"rect","circle","triangle"};
        for (String s:string) {
            if(s.equals("rect")){
                rect.draw();
            } else if (s.equals("triangle")) {
                triangle.draw();
            }else {
                circle.draw();
            }
        }
    }

    public static void main(String[] args) {
        Rect rect=new Rect();
        Circle circle=new Circle();
        Triangle triangle=new Triangle();
        Flower flower=new Flower();
        Shape[] shapes={rect,circle,triangle,flower};
        for (Shape s:shapes) {
            s.draw();
        }
    }
}
